package wikisearch.similarity;

import java.util.StringTokenizer;



public class CoOccurenceScoreFunction extends ScoreFunction {

	@Override
	public double calculateScore(String [] first, int fbeginIdx, int fendIdx, 
									String [] second, int sbeginIdx, int sendIdx) {
		
		int coOccur = 0;
		for (int f = fbeginIdx; f < fendIdx; f++) {
			for (int s = sbeginIdx; s < sendIdx; s++) {
				if ( first[f].equals(second[s]) ) {
					
					StringTokenizer st = new StringTokenizer(first[f]);
					coOccur += st.countTokens();
					//coOccur++;
				}
			}
		}
		return coOccur;
	}

}
